<?php
/**
 * Created by JetBrains PhpStorm.
 * User: avnovoselov
 * Date: 21.10.12
 * Time: 12:51
 * To change this template use File | Settings | File Templates.
 */
class url
{
    public static $host;
    public static $method;
    public static $uri;
    public static $uri_full;
    public static $uri_array;
    public static $mvc = array(
        'controller'    => 'main',
        'action'        => 'index',
        'id'            => 0,
    );

    public static function init()
    {
        $_SERVER['REDIRECT_URL'] = isset($_SERVER['REDIRECT_URL']) ? $_SERVER['REDIRECT_URL'] : '/';

        self::$host         = $_SERVER['HTTP_HOST'];
        self::$method       = count($_POST) ? 'POST' : 'GET';
        self::$uri          = $_SERVER['REDIRECT_URL'];
        self::$uri_full     = $_SERVER['REQUEST_URI'];
        self::$uri_array    = explode('/', $_SERVER['REDIRECT_URL']);

        self::$mvc['controller']    = !empty(self::$uri_array[1]) ? self::$uri_array[1] : self::$mvc['controller'];
        self::$mvc['action']        = !empty(self::$uri_array[2]) ? self::$uri_array[2] : self::$mvc['action'];
        self::$mvc['id']            = !empty(self::$uri_array[3]) ? self::$uri_array[3] : self::$mvc['id'];
    }
}
